package com.powernode.controller;

import com.powernode.util.MinIoUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @Author 梁卓
 * @Version 1.0
 * @ClassName FileUploadController
 * @Description 文件上传控制层
 * @Date 2024/07/28 16:54
 */
@Api("文件上传接口管理")
@RequestMapping("/admin/file")
@RestController
public class FileUploadController {

    @Resource
    private MinIoUtils minIoUtils;
    @Value("${minio.bucketName}")
    private String bucketName;


    /**
     * 单文件上传
     * @param file 文件对象
     * @return 文件上传后的url
     */
    @ApiOperation("单文件上传")
    @PostMapping("/upload/element")
    public String upload(MultipartFile file) {
        return minIoUtils.upload(file, bucketName);
    }

}
